#
# packet template
#
# Copyright (C) 2009 by chrisv <me@cv.gd>
#          
# See CREDITS for details about who has contributed to this project.
#
# For further information about the pdaXrom project and license conditions
# see the README file.
#

FUSE_VERSION=2.7.4
FUSE=fuse-${FUSE_VERSION}.tar.gz
FUSE_MIRROR=http://switch.dl.sourceforge.net/sourceforge/fuse
FUSE_DIR=$BUILD_DIR/fuse-${FUSE_VERSION}
FUSE_ENV="$CROSS_ENV_AC"

build_fuse() {
    test -e "$STATE_DIR/fuse.installed" && return
    banner "Build fuse"
    download $FUSE_MIRROR $FUSE
    extract $FUSE
    apply_patches $FUSE_DIR $FUSE
    pushd $TOP_DIR
    cd $FUSE_DIR
    (
    eval \
	$CROSS_CONF_ENV \
	$FUSE_ENV \
	./configure --build=$BUILD_ARCH --host=$TARGET_ARCH \
	    --prefix=/usr \
	    --sysconfdir=/etc \
	    || error
    ) || error "configure"
    
    make $MAKEARGS || error

	install_sysroot_files || error
	
	cd $TARGET_LIB
    
    for lib in libfuse.so.2.7.4 libulockmgr.so.1.0.1; do    	
		$INSTALL -D -m 644 $lib $ROOTFS_DIR/usr/lib/$lib || error
		$STRIP $ROOTFS_DIR/usr/lib/$lib
		create_so_compat_links $ROOTFS_DIR/usr/lib/$lib		
    done
    
	cd $FUSE_DIR/util
    for file in fusermount mount.fuse ulockmgr_server; do
    $INSTALL -D -m 755 $file $ROOTFS_DIR/usr/bin/$file || error	
    done
    
    cp -p init_script $ROOTFS_DIR/etc/init.d/fuse
    
    popd
    touch "$STATE_DIR/fuse.installed"
}
build_fuse
